<template>
	<view class="container">
		<view class="tab-box">
			<view class="top-tab">
				<button :class="one_tab_index==1 ? 'select' : ''" @click="one_tab_index=1">商品订单</button>
				<button :class="one_tab_index==2 ? 'select' : ''" @click="one_tab_index=2">服务订单</button>
			</view>
		</view>

		<view class="order-tab" v-if="one_tab_index==1">
			<view class="tab-item" :class="item.value==tab2_index?'select':''" v-for="(item,i) in tabList2" :key="i"
				@click="tab2_index=item.value,getQyOrder()">
				<text>{{item.text}}</text>
			</view>
		</view>
		<view class="order-tab" v-if="one_tab_index==2">
			<view class="tab-item" :class="i==tab2_index?'select':''" v-for="(item,i) in tabList_s" :key="i"
				@click="tab2_index=i">
				<text>{{item.text}}</text>
			</view>
		</view>

		<!-- <view class="s-t-box">
			<view class="dete-select">
				<uni-datetime-picker type="date" v-model="startTime" @maskClick="maskClick">
					<view class="date-picker">
						<text v-if="startTime" class="one-row">{{startTime}}</text>
						<text v-else class="placeholder">年/月/日</text>
						<image v-if="startTime" @click.stop="startTime=''" class="close"
							:src="$img_path('/pagesMine/63.png')" mode="widthFix"></image>
						<image v-else :src="$img_path('/pagesMine/74.png')" mode="widthFix"></image>
					</view>
				</uni-datetime-picker>
				<text>-</text>
				<uni-datetime-picker type="date" v-model="endTime" @maskClick="maskClick">
					<view class="date-picker">
						<text v-if="endTime" class="one-row">{{endTime}}</text>
						<text v-else class="placeholder">年/月/日</text>
						<image v-if="endTime" @click.stop="endTime=''" class="close"
							:src="$img_path('/pagesMine/63.png')" mode="widthFix"></image>
						<image v-else :src="$img_path('/pagesMine/74.png')" mode="widthFix"></image>
					</view>
				</uni-datetime-picker>
			</view>
			<button v-if="isExport" class="close" @click="isExport=false">取消</button>
			<button v-else class="export" @click="isExport=true">导出</button>
		</view> -->

		<view class="list" v-if="one_tab_index==1">
			<view class="item" v-for="item,index in arrayList" :key="index" @click="toDetail">
				<view class="order-on">
					<view class="left">
						<image v-if="false&&isExport" :src="$img_path('/pagesMine/14.png')" mode="widthFix"></image>
						<image v-if="true&&isExport" :src="$img_path('/pagesMine/15.png')" mode="widthFix"></image>
						<text>订单号：{{item.order_no}}</text>
					</view>
					<view v-if="item.state == 1">
						待支付
					</view>
					<view v-if="item.state == 2">
						待发货
					</view>
					<view v-if="item.state == 3">
						待收货
					</view>
					<view v-if="item.state == 4">
						待评论
					</view>
					<view v-if="item.state == 6">
						已完成
					</view>
					<view v-if="item.state == 7">
						已取消
					</view>
				</view>
				<view class="g-list">
					<view v-for="i,x in item.goods" :key="x" class="goods">
						<image :src="$img_base_url(i.image)" mode="aspectFill"></image>
						<view class="right">
							<view class="r-1">
								<view class="name one-row">
									{{i.title}}
								</view>
								<view class="price">
									<text>¥ </text>{{i.price}}
								</view>
							</view>
							<view class="r-2">
								<view class="spec">
									{{i.difference}}
								</view>
								<view class="num">
									x {{i.number}}
								</view>
							</view>
						</view>
					</view>
				</view>
				<!-- <view class="all-price">
					<text>含运费 需付款：</text>￥200.00
				</view> -->
			</view>
		</view>
		<view class="list" v-if="one_tab_index==2">
			<view class="s-item" @click="toDetail">
				<image v-if="false&&isExport" :src="$img_path('/pagesMine/14.png')" mode="widthFix"></image>
				<image v-if="true&&isExport" :src="$img_path('/pagesMine/15.png')" mode="widthFix"></image>
				<view class="info-box">
					<view class="t-1">
						<view class="name">
							家政服务名称
						</view>
						<view class="status"
							:style="{color:true ? '#FF4A4A' : true ? '#0291FF' : true ? '#000000' : '#FFCC26'}">
							<text v-if="true">已取消</text>
							<text v-if="false">待接单</text>
							<text v-if="false">待服务</text>
							<text v-if="false">服务中</text>
							<text v-if="false">待评价</text>
							<text v-if="false">已完成</text>
						</view>
					</view>
					<view class="t-2">
						<text>服务时间：</text>2024-05-20 今日21:00
					</view>
					<view class="t-3">
						<text>服务地址：</text>郑州市XXX区详情地址详情地址详情地址
					</view>
				</view>
			</view>
		</view>

		<view class="bottom-btn" v-if="isExport">
			<view class="b-box">
				<view class="left">
					<image v-if="false" :src="$img_path('/pagesMine/14.png')" mode="widthFix"></image>
					<image v-if="true" :src="$img_path('/pagesMine/15.png')" mode="widthFix"></image>
					<text>全选</text>
				</view>
				<button>确定导出</button>
			</view>
		</view>
	</view>
</template>

<script>
	import * as api from "@/utils/api/index.js";
	export default {
		data() {
			return {
				one_tab_index: 1,
				isExport: false,
				tabList1: [{
					text: '全部',
					value: 1
				}, {
					text: '商品',
					value: 1
				}, {
					text: '服务',
					value: 1
				}, {
					text: '委托',
					value: 1
				}, ],
				tabList2: [
					// 2=,3=待收货,4=,6=
					{
						text: '待发货',
						value: 2
					}, {
						text: '待收货',
						value: 3
					}, {
						text: '待评论',
						value: 4
					}, {
						text: '已完成',
						value: 6
					},
				],
				tabList_s: [{
					text: '全部',
					value: 1
				}, {
					text: '待接单',
					value: 1
				}, {
					text: '进行中',
					value: 1
				}, {
					text: '已完成',
					value: 1
				}, {
					text: '售后',
					value: 1
				}, ],
				tab1_index: 0,
				tab2_index: 2,
				startTime: '',
				endTime: '',
				arrayList: []
			};
		},
		onLoad() {
			this.getQyOrder()
			// this.userinfo = JSON.parse(uni.getStorageSync("userInfo"));
		},
		methods: {
			async getQyOrder() {
				let obj = {
					type: this.one_tab_index,
					order_state: this.tab2_index
				}
				const {
					code,
					data
				} = await api.getQyOrder(obj)
				if (code == 1) {
					this.arrayList = data.data
				}
			},

			toDetail() {
				// if(this.one_tab_index==1){
				// 	uni.navigateTo({
				// 		url:`/pagesRegion/salesOrder/goodsDetail`
				// 	})
				// }else{
				// 	uni.navigateTo({
				// 		url:`/pagesRegion/salesOrder/serviceDetail`
				// 	})
				// }
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 0 22rpx;
		box-sizing: border-box;

		.tab-box {
			padding-top: 20rpx;

			.top-tab {
				width: 472rpx;
				display: flex;
				height: 84rpx;
				border-radius: 84rpx;
				border: 2rpx solid #E72A2A;
				overflow: hidden;
				margin: 0 auto;

				button {
					flex: 1;
					font-weight: 400;
					font-size: 32rpx;
					color: #E72A2A;
					line-height: 84rpx;
					border-radius: 0;
					background-color: #FFFFFF;

					&:first-child {
						border-right: 2rpx solid #E72A2A;
					}

					&.select {
						color: #FFFFFF;
						background-color: #E72A2A;
					}
				}
			}
		}

		.s-t-box {
			display: flex;
			align-items: flex-end;
			justify-content: space-between;

			&>button {
				width: 166rpx;
				height: 56rpx;
				background: #FFFFFF;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				border: 2rpx solid #E72A2A;
				font-weight: 400;
				font-size: 28rpx;
				color: #E72A2A;
				line-height: 56rpx;

				&.close {
					border-color: #333333;
					color: #333333;
				}
			}
		}

		.dete-select {
			width: calc(100% - 186rpx);
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 20rpx;

			/deep/ .uni-date {
				width: calc(50% - 21rpx) !important;
			}

			.date-picker {
				width: 100%;
				height: 56rpx;
				background: #FFFFFF;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				border: 2rpx solid #B4B4B4;
				display: flex;
				align-items: center;
				padding: 0 20rpx;
				box-sizing: border-box;
				position: relative;

				text {
					display: block;
					width: calc(100% - 30rpx);
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 40rpx;

					&.placeholder {
						color: #B4B4B4;
					}
				}

				image {
					width: 30rpx;
					height: 30rpx;
				}
			}

			text {
				font-weight: 400;
				font-size: 36rpx;
				color: #000000;
				padding: 0 12rpx;
			}
		}

		.order-tab {
			// position: sticky;
			// top: 0;
			// left: 0;
			// right: 0;
			// margin-top: 20rpx;
			padding: 40rpx 0rpx 12rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			// background-color: #FFFFFF;
			z-index: 3;

			.tab-item {
				text {
					font-weight: 400;
					font-size: 32rpx;
					color: #333333;
					line-height: 44rpx;
					position: relative;
				}

				&.select {
					text {
						font-weight: bold;
						font-size: 32rpx;
						color: #E72A2A;
						line-height: 44rpx;

						&::after {
							content: '';
							width: 52rpx;
							height: 8rpx;
							background: #E72A2A;
							border-radius: 4rpx;
							position: absolute;
							top: calc(100% + 4rpx);
							left: 50%;
							transform: translateX(-50%);
						}
					}
				}
			}
		}

		.list {
			.item {
				padding: 0 22rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 12rpx 2rpx rgba(223, 223, 223, 0.16);
				border-radius: 20rpx;
				margin-top: 20rpx;
				box-sizing: border-box;

				.order-on {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-weight: bold;
					font-size: 28rpx;
					line-height: 40rpx;
					padding: 22rpx 0 0;

					.left {
						display: flex;
						align-items: center;

						image {
							width: 36rpx;
							height: 36rpx;
							margin-right: 12rpx;
						}

						text {
							color: #B4B4B4;
						}
					}
				}

				.g-list {
					padding-bottom: 28rpx;
					border-bottom: 2rpx solid #EEEEEE;

					.goods {
						display: flex;
						margin-top: 20rpx;

						image {
							width: 180rpx;
							height: 180rpx;
							border-radius: 20rpx;
						}

						.right {
							width: calc(100% - 180rpx);
							padding-left: 20rpx;
							box-sizing: border-box;

							.r-1 {
								display: flex;
								align-items: center;
								justify-content: space-between;
								padding-top: 12rpx;

								.name {
									width: calc(100% - 130rpx);
									font-weight: bold;
									font-size: 34rpx;
									color: #333333;
									line-height: 48rpx;
								}

								.price {
									font-weight: 900;
									font-size: 42rpx;
									color: #FF2E2E;
									line-height: 58rpx;

									text {
										font-size: 32rpx;
									}
								}
							}

							.r-2 {
								padding-top: 30rpx;
								font-weight: bold;
								font-size: 28rpx;
								color: #333333;
								line-height: 40rpx;
								display: flex;
								align-items: center;
								justify-content: space-between;
							}
						}
					}
				}

				.all-price {
					font-weight: bold;
					font-size: 32rpx;
					color: #FF4A4A;
					line-height: 44rpx;
					text-align: right;
					padding: 30rpx 0 40rpx;

					text {
						font-size: 24rpx;
						color: #929292;
					}
				}
			}

			.s-item {
				background: #FFFFFF;
				border-radius: 20rpx;
				padding: 26rpx 20rpx 42rpx 24rpx;
				box-sizing: border-box;
				margin-top: 20rpx;
				display: flex;
				align-items: center;

				&>image {
					width: 36rpx;
					height: 36rpx;
					padding-right: 20rpx;
				}

				.info-box {
					width: 100%;
				}

				.t-1 {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.name {
						font-weight: bold;
						font-size: 32rpx;
						color: #000000;
						line-height: 44rpx;
					}

					.status {
						font-weight: 400;
						font-size: 32rpx;
						line-height: 44rpx;
					}
				}

				.t-2,
				.t-3 {
					font-weight: bold;
					font-size: 28rpx;
					color: #000000;
					line-height: 40rpx;
					margin-top: 24rpx;

					text {
						font-weight: 400;
					}
				}
			}
		}

		.bottom-btn {
			width: 100%;
			height: 108rpx;
			box-sizing: content-box;
			padding-bottom: constant(safe-area-inset-bottom);
			padding-bottom: env(safe-area-inset-bottom);
			margin-top: 20rpx;

			.b-box {
				position: fixed;
				bottom: 0;
				left: 0;
				right: 0;
				padding-bottom: constant(safe-area-inset-bottom);
				padding-bottom: env(safe-area-inset-bottom);
				display: flex;
				align-items: center;
				justify-content: space-between;
				background-color: #FFFFFF;

				.left {
					display: flex;
					align-items: center;
					padding-left: 22rpx;

					image {
						width: 36rpx;
						height: 36rpx;
					}

					text {
						margin-left: 12rpx;
						font-weight: 400;
						font-size: 28rpx;
						color: #333333;
						line-height: 40rpx;
					}
				}

				button {
					width: 224rpx;
					height: 108rpx;
					background: #E72A2A;
					font-weight: 400;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 108rpx;
					border-radius: 0;
				}

				.con {}
			}
		}
	}
</style>